package com.aiex.framework.core.exception;

import com.aiex.framework.core.enums.ErrorCodeInterface;
import lombok.Getter;

import java.util.Objects;

@Getter
public class BaseException extends RuntimeException{

    private final Integer code;
    private final String msg;

    public BaseException(ErrorCodeInterface errorCode) {
        this.code = errorCode.getCode();
        this.msg = errorCode.getMsg();
    }

    public static void isTrue(Boolean condition, ErrorCodeInterface errorCode) throws BaseException {
        if(!condition){
            throw new BaseException(errorCode);
        }
    }

    public static void isEmpty(Object data, ErrorCodeInterface errorCode) throws BaseException {
        if(Objects.isNull(data)){
            throw new BaseException(errorCode);
        }
    }


}
